package com.security;

import java.util.Scanner;

/**
 * MD5 解密工具类
 * 
 * @author light
 * 
 */
public class MD5Decrypt {

	public static boolean decrypt(String plainText1, String plainText2, int bytes) {
		boolean match = false;
		String result = MD5Encrypt.encrypt(plainText2, bytes);
		if (plainText1 == result || plainText1.equals(result)) {
			match = true;
		}
		return match;
	}

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		System.out.print("请输入要解密的字符串：");
		String cipherText = input.next();
		
		String[] test=new String[]{"11111","1111111","abc","123","abcdefghijklmnopqrstuvwxyz",
				"12345678","Useradmin1","Useradmin123456","royasoft","123456","admin","Aa11111111","893535@roya"};
		boolean match=false;
		for(int i=0;i<test.length;i++){
			if(MD5Decrypt.decrypt(cipherText, test[i], 32)){
				match=true;
				System.out.println("解密结果是："+test[i]);
			}
		}
		if(!match){
			System.out.println("解密失败");
		}
	}

}
